package com.shop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.service.Sms_Coupon_Service;
import com.shop.pojo.sms.Sms_Coupon;
import com.shop.utils.LayuiUtils;
import com.shop.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/coupon")
public class Sms_Coupon_Controller {

    @Autowired
    private Sms_Coupon_Service sms_coupon_service;

    /**
     * 后台进行优惠卷显示页面
     * @param page
     * @param limit
     * @param sms_coupon
     * @return
     */
    @GetMapping("/find_admin_coupon_All")
    public LayuiUtils<Sms_Coupon> find_admin_coupon_All(Integer page, Integer limit, Sms_Coupon sms_coupon){
        System.out.println(page+"===="+limit);
        Page<Sms_Coupon> Pages = new Page<>(page, limit);

        return sms_coupon_service.find_admin_coupon_All(Pages,sms_coupon);

    }

    /**
     * 后台新增优惠卷方法
     * @param sms_coupon
     * @return
     */
    @PostMapping("/insert_admin_coupon_All")
    public R insert_admin_coupon_All(Sms_Coupon sms_coupon) throws ParseException {
        System.out.println(sms_coupon);
        return sms_coupon_service.insert_admin_coupon_All(sms_coupon);
    }


    @DeleteMapping("/delete_admin_coupon_All")
    public R delete_admin_coupon_All(@RequestParam List<Integer> id){

        return sms_coupon_service.delete_admin_coupon_All(id);
    }

    @PutMapping("/up_admin_coupon_All")
    public R up_admin_coupon_All(Sms_Coupon sms_coupon){
        return sms_coupon_service.up_admin_coupon_All(sms_coupon);
    }







}
